-
Notifications
You must be signed in to change notification settings - Fork 9
enable setting column Levels properties #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for this. Will try to have a look at it this weekend to give you some feedback. Adding some tick boxes below, but that's more for me to remember to do those on the PR later (though you are more than welcome to give it a go if you fancy):
|
|
@Remi-Gau thanks, let me know what you think of the proposed changes. If you decide they make sense, I'm happy to update the notebooks with examples. And sorry for the failed checks...I need to learn more about how this works! |
|
Finally taking the time to look into this. I like the way this is going. Just a couple of point before I start an "actual" review. tsv files have no header rowsI think there is one thing that this does is that this adds a header row to the TSV files of the stim files which is not OK by the BIDS standard. This is because A way to deal with this would be to create a Then stim files have no "holy trinity"The other problem is that this stim files are NOT required to have So in this case too we could rely on Does that make sense? |
by the way @TomasLenc if you want me to guide you on how to work with the unit tests and how you can use them to see what other changes will need to be added to the code, let me know. More than happy to explain it. |
|
Thanks for the feedback @Remi-Gau, I've looked up the rules for _stim file and changed the way the .tsv is saved. As you suggested, there is now a "isStim" field that controls the behavior depending on whether the file was initialized as _events or _stim. Not sure what your plan was regarding the actual saving within the _stim.tsv file. Assuming you may want to use the same idea as for the _events.tsv file, I patched parts of the code to make it possible (even when saving "event-by-event"). The way I did it is not very beautiful, so feel free to reject this :D |
Thanks, that would be super nice cause it hurts my heart to see everything failing after my PR :(( Did you want to link me to some tutorial, or perhaps you may have time to chat? Let me know, I'm aware you're busy! |
We can chat tomorrow if you have time. In the mean time you can have a look at this. Actually they have expanded it so I should probably have a look too. |
Will try to check it tonight. |
Remi-Gau
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is my review.
A couple of things need to be changed.
Some others are a bit more up to you.
Then there are some possibility to refactor the code in a couple of places.
|
@TomasLenc I have opened another PR #119 The plan for this one is just some doc to help people contribute to this repo. I think we should have a section on writing / using code tests. So if you have time to help with this. 😉 No pressure. |
|
I promise will fix at the tests tomorrow. |
Remi-Gau
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of things to change. Nothing big.
|
@all-contributors please add @TomasLenc code, ideas |
|
I've put up a pull request to add @TomasLenc! 🎉 |
Feeling honoured |
Changed order in which things are done when initializing. Now, all
the "holy trinity" columns and user-specified extra columns
are saved in the structure after calling saveEventsFile('init').
Next, the user can edit column properties before calling
saveEventsFile('open') which will write the JSON.
This way, Levels of e.g. trial_type can be set by the user. Moreover,
this gives the user the freedom to set the Levels as containers.Map
data type, which describes mapping between each level name and its
corresponding description. This is super useful because sometimes
levels can have cryptic names like '1' and '2', and so it's handy
to explain what each code means (e.g. 'left' and 'right' respectively).
Here is an example:
% allocate
logFile = [];
% We can define what extra columns we want in our tsv file beyond the
% BIDS holy trinity ('onset', 'duration', 'trial_type')
logFile.extraColumns = {'rhythm', 'trigger'};
% init logfile
logFile = saveEventsFile('init',cfg,logFile);
% change info about trial_type
logFile.columns.trial_type.Levels = containers.Map({'listen','tap'}, ...
{'listen without movement','tap finger with the pulse'});
% change units to miliseconds
logFile.columns.onset.Unit = 'ms';
logFile.columns.duration.Unit = 'ms';
% add info to the extra columns
logFile.extraColumns.rhythm.bids.Description = 'name of the rhythmic pattern';
logFile.extraColumns.rhythm.bids.Levels = {'unsyncopated','syncopated'};
logFile.extraColumns.trigger.bids.Description = 'EEG trigger value';
logFile.extraColumns.trigger.bids.Levels = containers.Map({'1','2'},{'low tone','high tone'});
% open tsv and write json for events
logFile = saveEventsFile('open',cfg,logFile);
Additional field .isStim is created in the logFile structure upon initialization (true if _stim file is requested, false otherwise). If _stim file is requested, no headers are printed in the .tsv file, and the standard columns "onset", "duration", "trial_type" are omitted.
Changes based on Remi-Gau's comments.
All unit tests are working with the updated functions. Also, applied some small changes requested in the review process for the PR.
|
hey @TomasLenc I did a rebase of this PR on the |
|
This |
Remi-Gau
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I am happy with this. I think that the related issues (continuous integration, documentation, jupyter book...) should be addressed in other PRs.
Codecov Report
@@ Coverage Diff @@
## dev #115 +/- ##
==========================================
- Coverage 81.06% 78.67% -2.40%
==========================================
Files 29 29
Lines 618 647 +29
==========================================
+ Hits 501 509 +8
- Misses 117 138 +21
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
|
@all-contributors please add @TomasLenc test |
|
I've put up a pull request to add @TomasLenc! 🎉 |
Changed order in which things are done when initializing. Now, all
the "holy trinity" columns and user-specified extra columns
are saved in the structure after calling saveEventsFile('init').
Next, the user can edit column properties before calling
saveEventsFile('open') which will write the JSON.
This way, Levels of e.g. trial_type can be set by the user. Moreover,
this gives the user the freedom to set the Levels as containers.Map
data type, which describes mapping between each level name and its
corresponding description. This is super useful because sometimes
levels can have cryptic names like '1' and '2', and so it's handy
to explain what each code means (e.g. 'left' and 'right' respectively).
Here is an example:
I hope this makes sense. I'm not sure about the _stim file bids rules, so I tried not to mess things up too much.